package com.xxl.job.executor.enums;

public enum DayCode {
    WORKDAY(0, "工作日"),
    HOLIDAY(1, "节假日"),
    WEEKEND(2, "双休日"),
    MAKEUP_DAY(3, "调休日");

    private final int code;
    private final String description;

    // 构造函数
    DayCode(int code, String description) {
        this.code = code;
        this.description = description;
    }

    // 获取代码的方法
    public int getCode() {
        return code;
    }

    // 获取描述的方法
    public String getDescription() {
        return description;
    }

    // 通过代码获取枚举常量的方法
    public static DayCode fromCode(int code) {
        for (DayCode dayCode : values()) {
            if (dayCode.getCode() == code) {
                return dayCode;
            }
        }
        throw new IllegalArgumentException("Invalid code: " + code);
    }

    // 重写 toString 方法
    @Override
    public String toString() {
        return description;
    }
}
